import axios from 'axios'

const API_URL = "http://localhost:8080/app/replies"

/**
 * 新增回复
 * replyInfo = { postId, parentId, userId, content }
 */
export const addReply = (replyInfo) => {
    return axios.post(`${API_URL}`, replyInfo)
}

/**
 * 获取某主楼的平铺回复列表
 * postId: 帖子 ID
 */
export const getRepliesByPost = (postId) => {
    return axios.get(`${API_URL}/post/${postId}`)
}

/**
 * 获取某主楼的树形楼中楼
 * postId: 帖子 ID
 */
export const getReplyTree = (postId) => {
    return axios.get(`${API_URL}/post/${postId}/tree`)
}

/**
 * 查询用户所有回复
 * userId: 用户 ID
 */
export const getRepliesByUser = (userId) => {
    return axios.get(`${API_URL}/user/${userId}`)
}
